/*
 * Copyright (C) 2011 Project R'yleh Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.Arkham;

public class Party {
	public Character[] characters = new Character[Constants.MAX_CHARACTERS];
	public Inventory inventory = new Inventory();
	
	public Party(){
		characters = new Character[10];
		inventory = new Inventory();
	}
	
	public void NewGame(){
		for( int i=0; i<Constants.MAX_CHARACTERS; i++)
			characters[i] = new Character();
		characters[0].newGame();
		characters[0].newLvl3Char();
		inventory.setMoney(100);
	}
	
	public boolean equip (int inventoryItem, int equipLocation, Character character){
		//if there is something equipped here, unequip.
		if(character.whatEquipped(equipLocation) != Armory.None){
			   inventory.unEquip(character.whatEquipped(equipLocation));
			   character.unequipItem(equipLocation);
		}
		//equips item within inventory
		if(!inventory.equip(inventoryItem, character.getName(), equipLocation))
			return false;		
		Item item = inventory.get(inventoryItem);
		character.equipItem(item, equipLocation);  //Sends item W/ equipped by tagged changed
		return true;
	}
	
	public boolean unequip (int equipLocation, Character character){
		Item item = character.whatEquipped(equipLocation);
		if(item == null)
			return false;

		character.unequipItem(equipLocation);
		inventory.unEquip(item);
		return true;
	}
}